package test

import config.MyFile
import org.apache.commons.io.FileUtils

import scala.io.Source
import scala.jdk.CollectionConverters._

object test6 extends MyFile {

  def main(args: Array[String]): Unit = {
    val path = "H:\\紫花苜蓿数据库\\2023_1_9\\变异"
    val file = s"$path/ALL_snp_analysis.frq".toFile

    Source.fromFile(file).getLines().grouped(100000).foreach { x =>
      x.map(_.split("\t")).groupBy(_.head).foreach { y =>

        FileUtils.writeLines(s"$path/snp_freq/${y._1}.txt".toFile, y._2.map(_.mkString("\t")).toBuffer.asJava , true)
      }


    }
  }

  def dealWithSnp = {
    val path = "H:\\紫花苜蓿数据库\\2022_12_19\\bianyi"
    val file = s"$path/indel.all.Annovar.xls".toFile

    Source.fromFile(file).getLines().grouped(100000).foreach { x =>
      x.map(_.split("\t")).groupBy(_.head).foreach { y =>

        FileUtils.writeLines(s"$path/indel/${y._1}.txt".toFile, y._2.map(_.mkString("\t")).toBuffer.asJava , true)
      }


    }
  }
}
